import redis
import json


def write_file():
    client = redis.StrictRedis(host='localhost', port=6379, db=0)

    key = '1111'+'calcreq'

    args={}
    nums = 100

    with open('./benchmarks/demo/交流电源系统.xml',encoding='utf-8') as f:
        model_data = f.read()
    args['xmlfile'] = model_data
    args['simulate_times'] = nums
    args['timeslice']=1
    args['result_home']=r'E:\\'
    args['seed']=1000


    client.set(key,json.dumps(args))

    print(client.get(key))

def clear_db():
    client = redis.StrictRedis(host='localhost', port=6379, db=0)
    client.flushdb()

def show_file():
    client = redis.StrictRedis(host='localhost', port=6379, db=0)

    key = '0001'+'calcprog'

    #key = '0001'+'calcreq'


    client.get(key)

    print(client.get(key))

if __name__ == '__main__':
    show_file()